package com.eleadmin.order.service.impl;

import com.eleadmin.common.core.web.JsonResult;
import com.eleadmin.common.system.entity.User;
//import com.eleadmin.order.mapper.ContainerBillFeeMapper;
import com.eleadmin.damon.utils.results.PageResult2;
import com.eleadmin.order.entity.ContainerBillFee;
import com.eleadmin.order.service.ContainerBillFeeService;
import org.springframework.stereotype.Service;
import com.eleadmin.order.biz.ContainerBillFeeBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 订单运费服务实现类
 * @author : Doman
 * @date : 2023-03-24 15:37:47
 * @version ：1.0
 */
@Service
public class ContainerBillFeeServiceImpl /*extends ServiceImpl<ContainerBillFeeMapper, ContainerBillFee> */implements ContainerBillFeeService {

    @Autowired
    private ContainerBillFeeBiz containerBillFeeBiz;

    @Override
    public JsonResult list(PageResult2<T> page, ContainerBillFee containerBillFee, User loginUser)  throws Exception{
        return containerBillFeeBiz.list(page,containerBillFee,loginUser);
    }

    @Override
    public JsonResult list(ContainerBillFee containerBillFee, User loginUser) {
        return JsonResult.ok().setData(containerBillFeeBiz.list(containerBillFee,loginUser));
    }

    @Override
    public JsonResult getById(String id) {
        return JsonResult.ok().setData(containerBillFeeBiz.getById(id));
    }

    @Transactional
    @Override
    public JsonResult save(ContainerBillFee containerBillFee, User loginUser) {
        if (containerBillFeeBiz.save(containerBillFee, loginUser)) {
            return JsonResult.ok("添加成功");
        }
        return JsonResult.error("添加失败");
    }

    @Transactional
    @Override
    public JsonResult update(ContainerBillFee containerBillFee, User loginUser) {
        if (containerBillFeeBiz.update(containerBillFee, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(String id, User loginUser) {
        if (containerBillFeeBiz.remove(id, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
